package mmoon.mmoonstory.items;

import mmoon.mmoonstory.EasyCommand;
import mmoon.mmoonstory.MMoonUtils;
import mmoon.mmoonstory.interfaces.InitItem;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.TextComponentString;

public class ItemMagicStick extends Item implements InitItem {
    public static final String ObjID = "magic_stick";

    public ItemMagicStick() {
        super();
        this.setMaxStackSize(1);
        this.init(ObjID);
    }

    @Override
    public boolean onLeftClickEntity(ItemStack stack, EntityPlayer player, Entity entity) {
        if (!entity.world.isRemote) {
            if (entity instanceof EntityLivingBase) {
                double amount = EasyCommand.getAttr((EntityLivingBase) entity, MMoonUtils.MagicPower);
                player.sendMessage(new TextComponentString("This entity has magic power of " + amount));
                return true;
            }
        }
        return false;
    }

    @Override
    public int getItemBurnTime(ItemStack itemStack) {
        return Integer.MAX_VALUE;
    }
}
